var
  i,j,k,m,n,s,t,x,y:longint;
begin
  read(n,m);
  if n>m then begin t:=n; n:=m; m:=t; end;
  if n=1 then n:=2;
  i:=n;
  while m>=i do
  begin
    t:=1;
    for j:=2 to trunc(sqrt(i)) do
    if i mod j=0 then begin t:=0; break; end;
    if t=1 then s:=s+1;
    i:=i+1;
    if (i<>2) and (i mod 2=0) then i:=i+1;
  end;
  writeln(s);
end.
